/*
MayPack v0.1
Copyright (c) 2021 Majjcom
licence:	MIT
Date:		2021/12/16
FILE:		maypack.h
*/
#ifndef __MAYPACK_H__
#define __MAYPACK_H__

#include <vector>
#include <string>
#include "mayjson/may.h"

namespace maypack
{
	int packUp(std::vector<std::string> packs, const int count, const char fout[]);

	class Package
	{
	private:
		const char* _name;
		const char* _info_s;
		mayjson::Json _info;
		std::vector<mayjson::Json*> _fileList;
		int _start_pos;
		bool _is_closed = false;
		bool _is_setuped = false;
		struct FileInfo;
		void _prase_info(FILE* fp_in);
		void _prase_list();
		void _cleanUp();
		FileInfo _get_file_info(const char* name);
	public:
		void setUp(const char* fin);
		Package(const char* fin);
		Package();
		~Package();
		std::vector<std::string> getFileList();
		int getFileSize(const char* name);
		int unPack(const char* name);
		int unPackAll();
		void close();
	};
}

#endif
